import request from "@/utlis/request";
import type {
  ILoginForm,
  ILoginResponseData,
  IUserResponseData,
  ILogoutResponseData,
} from "./type";

//统一管理接口
enum API {
  LOGIN_URL = "/login",
  USERINFO_URL = "/user/findByName",
  LOGOUT_URL = "/getLogout",
}

//登录接口
export const reqLogin = async (data: ILoginForm) => {
  return await request.post<any, ILoginResponseData>(API.LOGIN_URL, data);
};

//获取用户信息
export const reqUserInfo = async (name: string) => {
  return await request.get<any, IUserResponseData>(
    API.USERINFO_URL + `?name=${name}`,
  );
};

//退出登录
export const reqLogout = async () => {
  return await request.post<any, ILogoutResponseData>(API.LOGOUT_URL);
};
